.class public Lcom/xiaomi/notes/Widget;
.super Landroid/appwidget/AppWidgetProvider;
.source "Widget.java"


# instance fields
.field private db:Lcom/xiaomi/notes/DBOperate;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 14
    invoke-direct {p0}, Landroid/appwidget/AppWidgetProvider;-><init>()V

    .line 15
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    return-void
.end method

.method private getNoteColorResId(I)I
    .locals 1
    .parameter "color"

    .prologue
    .line 88
    const v0, 0x7f02004f

    .line 89
    .local v0, ret:I
    packed-switch p1, :pswitch_data_0

    .line 107
    :goto_0
    return v0

    .line 91
    :pswitch_0
    const v0, 0x7f02004f

    .line 92
    goto :goto_0

    .line 94
    :pswitch_1
    const v0, 0x7f02004e

    .line 95
    goto :goto_0

    .line 97
    :pswitch_2
    const v0, 0x7f02004b

    .line 98
    goto :goto_0

    .line 100
    :pswitch_3
    const v0, 0x7f02004d

    .line 101
    goto :goto_0

    .line 103
    :pswitch_4
    const v0, 0x7f02004c

    goto :goto_0

    .line 89
    nop

    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_0
        :pswitch_1
        :pswitch_2
        :pswitch_3
        :pswitch_4
    .end packed-switch
.end method


# virtual methods
.method public onDeleted(Landroid/content/Context;[I)V
    .locals 6
    .parameter "context"
    .parameter "appWidgetIds"

    .prologue
    const/4 v5, 0x0

    .line 71
    new-instance v1, Lcom/xiaomi/notes/DBOperate;

    invoke-direct {v1}, Lcom/xiaomi/notes/DBOperate;-><init>()V

    iput-object v1, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    .line 73
    :try_start_0
    iget-object v1, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    invoke-virtual {v1, p1}, Lcom/xiaomi/notes/DBOperate;->openDB(Landroid/content/Context;)V

    .line 74
    const/4 v0, 0x0

    .local v0, i:I
    :goto_0
    array-length v1, p2

    if-ge v0, v1, :cond_0

    .line 75
    iget-object v1, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    const/4 v2, 0x0

    aget v3, p2, v0

    const/4 v4, 0x0

    invoke-virtual {v1, v2, v3, v4}, Lcom/xiaomi/notes/DBOperate;->updateWidget(III)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 74
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 79
    :cond_0
    iget-object v1, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    invoke-virtual {v1}, Lcom/xiaomi/notes/DBOperate;->close()V

    .line 80
    iput-object v5, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    .line 82
    return-void

    .line 79
    .end local v0           #i:I
    :catchall_0
    move-exception v1

    iget-object v2, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    invoke-virtual {v2}, Lcom/xiaomi/notes/DBOperate;->close()V

    .line 80
    iput-object v5, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    throw v1
.end method

.method public onUpdate(Landroid/content/Context;Landroid/appwidget/AppWidgetManager;[I)V
    .locals 11
    .parameter "context"
    .parameter "appWidgetManager"
    .parameter "appWidgetIds"

    .prologue
    const/4 v10, 0x1

    .line 19
    new-instance v6, Landroid/widget/RemoteViews;

    invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v7

    const v8, 0x7f03000d

    invoke-direct {v6, v7, v8}, Landroid/widget/RemoteViews;-><init>(Ljava/lang/String;I)V

    .line 20
    .local v6, views:Landroid/widget/RemoteViews;
    new-instance v7, Lcom/xiaomi/notes/DBOperate;

    invoke-direct {v7}, Lcom/xiaomi/notes/DBOperate;-><init>()V

    iput-object v7, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    .line 22
    :try_start_0
    iget-object v7, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    invoke-virtual {v7, p1}, Lcom/xiaomi/notes/DBOperate;->openDB(Landroid/content/Context;)V

    .line 23
    const/4 v0, 0x0

    .local v0, i:I
    :goto_0
    array-length v7, p3

    if-ge v0, v7, :cond_2

    .line 24
    iget-object v7, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    const/4 v8, 0x0

    aget v9, p3, v0

    invoke-virtual {v7, v8, v9}, Lcom/xiaomi/notes/DBOperate;->getWidget(II)Ljava/util/Map;

    move-result-object v1

    .line 26
    .local v1, info:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    if-eqz v1, :cond_1

    .line 27
    const-string v7, "content"

    invoke-interface {v1, v7}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    .line 28
    .local v5, text:Ljava/lang/String;
    const-string v7, "bgcolorId"

    invoke-interface {v1, v7}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Ljava/lang/Integer;

    invoke-virtual {v7}, Ljava/lang/Integer;->intValue()I

    move-result v3

    .line 29
    .local v3, nBg:I
    const v7, 0x7f07004c

    invoke-virtual {v6, v7, v5}, Landroid/widget/RemoteViews;->setTextViewText(ILjava/lang/CharSequence;)V

    .line 30
    if-lt v3, v10, :cond_0

    const/4 v7, 0x5

    if-gt v3, v7, :cond_0

    .line 32
    const v7, 0x7f07004c

    sget-object v8, Lcom/xiaomi/notes/Tools;->N_WIDGET_TEXT_COLOR:[I

    sub-int v9, v3, v10

    aget v8, v8, v9

    invoke-virtual {v6, v7, v8}, Landroid/widget/RemoteViews;->setTextColor(II)V

    .line 34
    :cond_0
    const v7, 0x7f07004b

    invoke-direct {p0, v3}, Lcom/xiaomi/notes/Widget;->getNoteColorResId(I)I

    move-result v8

    invoke-virtual {v6, v7, v8}, Landroid/widget/RemoteViews;->setImageViewResource(II)V

    .line 36
    new-instance v2, Landroid/content/Intent;

    const-string v7, "android.intent.action.VIEW"

    invoke-direct {v2, v7}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 37
    .local v2, intent:Landroid/content/Intent;
    new-instance v7, Landroid/content/ComponentName;

    const-class v8, Lcom/xiaomi/notes/NoteListActivity;

    invoke-direct {v7, p1, v8}, Landroid/content/ComponentName;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    invoke-virtual {v2, v7}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;

    .line 38
    const-string v7, "DESKTOP_TO_APP_FLAG_TYPE"

    const/4 v8, 0x3

    invoke-virtual {v2, v7, v8}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 40
    const-string v7, "DESKTOP_TO_APP_FLAG_ID"

    aget v8, p3, v0

    invoke-virtual {v2, v7, v8}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 41
    const-string v7, "DESKTOP_TO_APP_FLAG_EXPAND"

    const/4 v8, 0x0

    invoke-virtual {v2, v7, v8}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 43
    aget v7, p3, v0

    const/high16 v8, 0x800

    invoke-static {p1, v7, v2, v8}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v4

    .line 45
    .local v4, sender:Landroid/app/PendingIntent;
    const v7, 0x7f07004c

    invoke-virtual {v6, v7, v4}, Landroid/widget/RemoteViews;->setOnClickPendingIntent(ILandroid/app/PendingIntent;)V

    .line 47
    aget v7, p3, v0

    invoke-virtual {p2, v7, v6}, Landroid/appwidget/AppWidgetManager;->updateAppWidget(ILandroid/widget/RemoteViews;)V

    .line 23
    .end local v3           #nBg:I
    .end local v5           #text:Ljava/lang/String;
    :goto_1
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 49
    .end local v2           #intent:Landroid/content/Intent;
    .end local v4           #sender:Landroid/app/PendingIntent;
    :cond_1
    const v7, 0x7f07004c

    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v8

    const v9, 0x7f050013

    invoke-virtual {v8, v9}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v6, v7, v8}, Landroid/widget/RemoteViews;->setTextViewText(ILjava/lang/CharSequence;)V

    .line 51
    const v7, 0x7f07004c

    sget-object v8, Lcom/xiaomi/notes/Tools;->N_WIDGET_TEXT_COLOR:[I

    const/4 v9, 0x0

    aget v8, v8, v9

    invoke-virtual {v6, v7, v8}, Landroid/widget/RemoteViews;->setTextColor(II)V

    .line 52
    const v7, 0x7f07004b

    const v8, 0x7f02004f

    invoke-virtual {v6, v7, v8}, Landroid/widget/RemoteViews;->setImageViewResource(II)V

    .line 54
    new-instance v2, Landroid/content/Intent;

    const-string v7, "android.intent.action.VIEW"

    invoke-direct {v2, v7}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 55
    .restart local v2       #intent:Landroid/content/Intent;
    new-instance v7, Landroid/content/ComponentName;

    const-class v8, Lcom/xiaomi/notes/NoteListActivity;

    invoke-direct {v7, p1, v8}, Landroid/content/ComponentName;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    invoke-virtual {v2, v7}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;

    .line 56
    const/4 v7, 0x0

    const/high16 v8, 0x800

    invoke-static {p1, v7, v2, v8}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v4

    .line 58
    .restart local v4       #sender:Landroid/app/PendingIntent;
    const v7, 0x7f07004c

    invoke-virtual {v6, v7, v4}, Landroid/widget/RemoteViews;->setOnClickPendingIntent(ILandroid/app/PendingIntent;)V

    .line 60
    aget v7, p3, v0

    invoke-virtual {p2, v7, v6}, Landroid/appwidget/AppWidgetManager;->updateAppWidget(ILandroid/widget/RemoteViews;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_1

    .line 64
    .end local v0           #i:I
    .end local v1           #info:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    .end local v2           #intent:Landroid/content/Intent;
    .end local v4           #sender:Landroid/app/PendingIntent;
    :catchall_0
    move-exception v7

    iget-object v8, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    invoke-virtual {v8}, Lcom/xiaomi/notes/DBOperate;->close()V

    .line 65
    const/4 v8, 0x0

    iput-object v8, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    throw v7

    .line 64
    .restart local v0       #i:I
    :cond_2
    iget-object v7, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    invoke-virtual {v7}, Lcom/xiaomi/notes/DBOperate;->close()V

    .line 65
    const/4 v7, 0x0

    iput-object v7, p0, Lcom/xiaomi/notes/Widget;->db:Lcom/xiaomi/notes/DBOperate;

    .line 67
    return-void
.end method
